package chapter01

class Student(name: String, var age: Int) {
  def printInfo(): Unit = {
    println(name + " " + age + " " + Student.school)
  }
}

//引入伴生对象,相当于将静态变量和静态方法移动到了object开头的文件中
object Student {
  val school: String = "cobra"

  def main(args: Array[String]): Unit = {
    val alice = new Student("alice", 20)
    alice.printInfo()
  }
}
